import { createSlice, PayloadAction } from '@reduxjs/toolkit'

interface UserProfile {
  fullName?: string
  phone?: string
  bio?: string
  education?: string
  occupation?: string
}

interface UserState {
  profile: UserProfile | null
  loading: boolean
}

const initialState: UserState = {
  profile: null,
  loading: false,
}

const userSlice = createSlice({
  name: 'user',
  initialState,
  reducers: {
    setProfile: (state, action: PayloadAction<UserProfile>) => {
      state.profile = action.payload
    },
    setLoading: (state, action: PayloadAction<boolean>) => {
      state.loading = action.payload
    },
  },
})

export const { setProfile, setLoading } = userSlice.actions
export default userSlice.reducer
